package util;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Regex {
	public static ArrayList<String> allMatches(String exp, String mstr){
		ArrayList<String> matches = new ArrayList<String>();
		
		Pattern p = Pattern.compile(exp);
		Matcher m = p.matcher(mstr);
		while (m.find()) {
			matches.add(m.group());
		}
		
		return matches;
	}
	
	public static String firstMatch(String exp, String mstr){
		Pattern p = Pattern.compile(exp);
		Matcher m = p.matcher(mstr);
		if (m.find()) {
			return m.group();
		}
		else{
			return null;
		}
	}
}
